﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using WMSSoft.Lib.Basic;
using WMSSoft.Lib.WinKStart.ViewModel;

namespace WMSSoft.Lib.WinKStart.Abstract
{
    public abstract class SettingBaseListViewModel : CSettingsBaseViewModel
    {
        public event EventHandler ViewModel_AddClick;
        public event EventHandler ViewModel_EditClick;
        public event EventHandler ViewModel_DeleteClick;

        public SettingBaseListViewModel()
        {
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Add"), new CDelegatingCommand(Delegate => this.Cmd_Exec_AddClick())));
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Edit"), new CDelegatingCommand(Delegate => this.Cmd_Exec_EditClick())));
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Delete"), new CDelegatingCommand(Delegate => this.Cmd_Exec_DeleteClick())));
        }

        void Cmd_Exec_AddClick()
        {
            if (ViewModel_AddClick != null) ViewModel_AddClick(this, EventArgs.Empty);
        }

        void Cmd_Exec_EditClick()
        {
            if (ViewModel_EditClick != null) ViewModel_EditClick(this, EventArgs.Empty);
        }

        void Cmd_Exec_DeleteClick()
        {
            if (ViewModel_DeleteClick != null) ViewModel_DeleteClick(this, EventArgs.Empty);
        }

        public CSingleCommandViewModel Cmd_AddClick
        {
            get { return m_oCommands[3]; }
        }

        public CSingleCommandViewModel Cmd_EditClick
        {
            get { return m_oCommands[4]; }
        }

        public CSingleCommandViewModel Cmd_DeleteClick
        {
            get { return m_oCommands[5]; }
        }
    }
}
